<?php
namespace app\admin\controller;

use app\common\model\Extract;


class Deposit extends CheckLogin
{
    //申请体现呢列表
    public function index() {
        if ($this->request->isAjax()) {
            $page = (int)$this->request->post('pageIndex');
            $limit = (int)$this->request->post('pageSize');
            $status = $this->request->post('dataStatus', -1);
            $offset = ($page - 1) * $limit;
            $where = [];
            if($status != -1) $where['status'] = $status;
            $extract = new Extract();
            $totalCount = $extract->where($where)->count();
            $list = $totalCount > 0 ? $extract->allExtract($where, $offset, $limit) : [];
            if (!empty($list)) {
                $status = Extract::$status;
                foreach($list as $key => $val) {
                    $list[$key]['user_id_format'] = $val->user->nickname;
                    $list[$key]['status_format'] = $status[$val['status']];
                }
            }
            $data = [
                'code' => 0,
                'msg' => 'success',
                'list' => $list,
                'count' => $totalCount
            ];

            return $this->json($data);
        } else {
            $this->assign('status', Extract::$status);
            return $this->fetch();
        }
    }


    // 同意提现
    public function handle()
    {

    }

}
